<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<html>
<head>
<link href="<c:url value="/resources/homepage.css" />" rel="stylesheet">
    <link href="<c:url value="/resources/tcal.css" />" rel="stylesheet">
 <script type="text/javascript" src="<c:url value="/resources/tcal.js" />"></script> 
    
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CreateStory</title>
<script>

function validateform()
{
	var st=document.forms["myform"]["story_title"].value;
	var sd=document.forms["myform"]["story_description"].value;
	var so=document.forms["myform"]["story_owner"].value;
	var ac=document.forms["myform"]["acceptance_criteria"].value;
	var psd=document.forms["myform"]["planned_start_date"].value;
	var ped=document.forms["myform"]["planned_end_date"].value;
	var asd=document.forms["myform"]["actual_start_date"].value;
	var aed=document.forms["myform"]["actual_end_date"].value;
	var ae=document.forms["myform"]["actual_effort"].value;
	var rf=document.forms["myform"]["remaining_effort"].value;
	var regex = /^[a-zA-Z0-9]*$/;

	
	var spi=document.forms["myform"]["story_point_id"].value;
	var si=document.forms["myform"]["status_id"].value;
	var ci=document.forms["myform"]["complexity_id"].value;
	var pi=document.forms["myform"]["priority_id"].value;

	
	
	if(st==null || st=="")
		{
			alert("story title must be filed");
			//return false;
		}

	if(sd==null || sd=="")
	{
		alert("story description must be filed");
		//return false;
	}
	
	if(regex.test(st))
		{
		alert("story title must be String");
		}
	
	if(regex.test(sd))
	{
	alert("story description must be String");
	}
	
	if(so==null || so=="")
	{
		alert("story owner must be filed");
		//return false;
	}

	if(psd==null || psd=="")
	{
		alert("planned start date must be filed");
		return false;
	}

	if(ped==null || ped=="")
	{
		alert("planned end date must be filed");
		return false;
	}

	if(asd==null || asd=="")
	{
		alert("actual start date must be filed");
		return false;
	}

	if(aed==null || aed=="")
	{
		alert("actual end date must be filed");
		return false;
	}
	if(ae==null || ae=="")
	{
		alert("actual effort must be filed");
		return false;
	}

	if(re==null || re=="")
	{
		alert("remaining effort must be filed");
		return false;
	}

	if(ac==null || ac=="")
	{
		alert("acceptance criteria must be filed");
		return false;
	}


	if(pi==null || pi=="" || pi==" ")
	{
		alert("Priority must be selected");
		return false;
	}
	
	if(spi==null || spi=="" || spi==" ")
	{
		alert("Planned effort must be selected");
		return false;
	}

	if(si==null || si=="" || si==" ")
	{
		alert("Status must be selected");
		return false;
	}

	if(ci==null || ci=="" || ci==" ")
	{
		alert("Complexity must be selected");
		return false;
	}

	
	if(re > ae)
	{
		alert("remaining effort should be less than actual effort");
		return false;		
	}
}
</script>
</head>
<body>
	<div id="wrapper">
		<!-- ============ HEADER SECTION ============== -->
		<div id="header">
			<div id="headerlogo"></div>
		</div>
		<!-- ============ NAVIGATION SECTION ============== -->
		<div id="menubar">

			<ul>
<li><a href="Project">Projects</a></li>
					<li><a href="Backlog" ><span class="currentLink">Backlog</span></a></li>
					<li><a href="SprintPlanning">Sprint Planning</a></li>
					<li><a href="Storyboard1">Sprint Tracking</a></li>
					<li><a href="logout">Logout</a></li>
		</ul>
		</div>

		<!-- ============ MIDDLE SECTION ============== -->
		<div id="m1">
			<fieldset>
				<legend>
					<h3>Story Details</h3>
				</legend>
				<form:form name="myform" action="saveStory"  onsubmit="return validateform();"  method="get" modelAttribute="story">
				<form:hidden path="story_id" value='0'/>
 				<form:hidden path="project_id" value='<%=request.getParameter("project_id")%>'/> 
						<table>
						<tr>
							<td>Story Title</td>
							<td><form:input path="story_title" size="22" /><font color="red"></font></td>
							<td></td>
							<td>Complexity</td>
							<td><form:select path="complexity_id">
									<option value="">-- Select Complexity from List --</option>
									<c:forEach var="complexity" items="${listcomplexity}">
										<option value='<c:out value="${complexity.complexity_id}"/>'>
											<c:out value="${complexity.complexity_name}" />
										</option>
									</c:forEach>
							</form:select></td>
						</tr>
						<tr>
							<td>Description</td>
							<td>  <form:textarea path="story_description" rows="5" cols="33" /></td>
							<td></td>
							<td>Planned Effort</td>
							<td><form:select path="story_point_id">
									<option value="">-- Select story points from List --</option>
									<c:forEach var="storypoints" items="${liststorypoint}">
										<option value='<c:out value="${storypoints.story_point_id}"/>'>
											<c:out value="${storypoints.story_point}" />
										</option>
									</c:forEach>
							</form:select></td>
						</tr>
						<tr>
							<td>Owner</td>
							<td><form:input path="story_owner" size="22"/></td>
							<td></td>
							<td>Actual Effort</td>
							<td><form:input path="actual_effort" size="22"/></td>
						</tr>
						<tr>
							<td>Priority</td>
							<td><form:select path="priority_id">
									<option value="">-- Select priority from List --</option>
									<c:forEach var="priority" items="${listpriority}">
										<option value='<c:out value="${priority.priority_id}"/>'>
											<c:out value="${priority.priority_name}" />
										</option>
									</c:forEach>
							</form:select></td>
							<td></td>
							<td>Remaining Effort</td>
							<td><form:input path="remaining_effort" size="22"/></td>
						</tr>
						<tr>
							<td>Planned Start Date</td>
							<td><form:input path="planned_start_date" class="tcal" /><font color="red">[yyyy-mm-dd]</font></td>
							<td></td>
							<td>Actual Start Date</td>
							<td><form:input path="actual_start_date" class="tcal" /><font color="red">[yyyy-mm-dd]</font></td>

						</tr>
						<tr>
							<td>Planned End Date</td>
							<td><form:input path="planned_end_date" class="tcal" /><font color="red">[yyyy-mm-dd]</font></td>
							<td></td>
							<td>Actual End Date</td>
							<td><form:input path="actual_end_date" class="tcal" /><font color="red">[yyyy-mm-dd]</font></td>

						</tr>
						<tr>
							<td>Status</td>
							<td><form:select path="status_id">
									<option value="">-- Select status from List --</option>
									<c:forEach var="status" items="${liststatus}">
										<option value='<c:out value="${status.status_id}"/>'>
											<c:out value="${status.status_name}" />
										</option>
									</c:forEach>
							</form:select></td>
							<td></td>
							<td>Acceptance Criteria</td>
							<td><form:input path="acceptance_criteria" size="22"/></td>
						</tr>
						<tr>
							<td></td>
							<td></td>
							<td><input type="submit" value="Save"></td>
							<td><input type="submit" value="CANCEL"
								align="right"></td>
						</tr>
					</table>
			</form:form>
			</fieldset>
		</div>
		
		<div id="footer">
			<p>Copyright &copy; 2014 - All Rights Reserved - Spring Computing
				Pvt. Ltd.</p>
		</div>
	</div>


</body>
</html>